package com.bustle.commons;

import java.util.Collection;

import javax.ejb.Local;
import javax.ejb.Stateless;

@Local
public interface CollectionManager
{
  public <SourceElementType, DestinationElementType> void addAll(Collection<SourceElementType> aSource, Collection<DestinationElementType> aDestination, Converter<SourceElementType, DestinationElementType> anElementConverter);

  @Stateless
  public class DefaultCollectionManager implements CollectionManager
  {
    @Override
    public <SourceElementType, DestinationElementType> void addAll(Collection<SourceElementType> aSource, Collection<DestinationElementType> aDestination, Converter<SourceElementType, DestinationElementType> anElementConverter)
    {
      for (SourceElementType sourceElement : aSource)
      {
        aDestination.add(anElementConverter.convert(sourceElement));
      }
    }
  }
}
